﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using SqlCon;
using CrystalDecisions.CrystalReports.Engine;
using System.Drawing.Printing;

namespace yfxt
{
    public partial class cx_yfkc_dy : Form
    {
        cx_yfkc yfkc;

        public cx_yfkc_dy()
        {
            InitializeComponent();
        }
        SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction);
        private void cx_yfkc_dy_Load(object sender, EventArgs e)
        {
            yfkc=(cx_yfkc)this.Owner;

            string s;        
            if (conn.State != ConnectionState.Open) { conn.Open(); }
            if (yfkc.s_temp.ToString().Equals(""))
            {
                   s = "select  yk_typk.pydm as pydm,ypmc,ypgg,ypdw,cdmc,yf_kcmx.lsjg as lsjg,yf_kcmx.ypsl as kcsl, " +
                       " (yf_kcmx.lsjg*yf_kcmx.ypsl)as kcje  " +
                       " from yk_typk,yf_kcmx,yk_ypcd,yk_cddz where yk_typk.ypxh=yf_kcmx.ypxh " +
                       " and yk_ypcd.ypxh=yk_typk.ypxh and yk_ypcd.ypcd=yk_cddz.ypcd" +
                       " group by  yk_typk.pydm,ypmc,ypgg,ypdw,cdmc,yf_kcmx.lsjg,yf_kcmx.ypsl";

            }
            else 
            {
                      s = "select  yk_typk.pydm as pydm,ypmc,ypgg,ypdw,cdmc,yf_kcmx.lsjg as lsjg,yf_kcmx.ypsl as kcsl, " +
                       " (yf_kcmx.lsjg*yf_kcmx.ypsl)as kcje " +
                       " from yk_typk,yf_kcmx,yk_ypcd,yk_cddz where yk_typk.ypxh=yf_kcmx.ypxh " +
                       " and yk_ypcd.ypxh=yk_typk.ypxh and yk_ypcd.ypcd=yk_cddz.ypcd" +
                       " and yk_typk.pydm like '" + yfkc.s_temp.ToString()+"%'"+
                       " group by  yk_typk.pydm,ypmc,ypgg,ypdw,cdmc,yf_kcmx.lsjg,yf_kcmx.ypsl";

            }


            DS_yfkc yfkc_01 = new DS_yfkc();

            SqlDataAdapter da = new SqlDataAdapter(s,conn);

            da.Fill(yfkc_01,"yfkc");

            //Cry_yfkc Cyfkc = new Cry_yfkc();

            //Cyfkc.SetDataSource(yfkc_01);

            //crystalReportViewer1.ReportSource = Cyfkc;

            
        }
    }
}
